#pragma once

#include "Service/IServiceManager.h"

class ServiceManager : public IServiceManager
{
	typedef std::map<String,vclsid> ServiceProviderRegistration;
	typedef std::map<String,sys::ObjectPtr> ServiceProviderCache;

public:
	BEGIN_DEFINE_CLASS(CLSID_ServiceManager)
		DEFINE_INTERFACE_ENTRY(IServiceManager)
	END_DEFINE_CLASS()

	ServiceManager();
	virtual ~ServiceManager();

	virtual void RegisterServiceProvider(const String& service,vclsid clsidServiceProvider);
	virtual void ReplaceServiceProvider(const String& service,vclsid clsidServiceProvider);
	virtual IObject* GetServiceProvider(const String& service) const;

private:
	ServiceProviderRegistration m_registrations;
	mutable ServiceProviderCache m_serviceProviderCache;
};
AUTO_REGISTER_CLASSMAP_ENTRY_singleton(ServiceManager)
